package upicgame.entity;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;
@Entity
@Table(name = "library")
public class Library {
	private Integer id;
	private User user;
	private Game game;
	public Library() {
		
	}
	public Library(Integer id, User user, Game game) {
		super();
		this.id = id;
		this.user = user;
		this.game = game;
	}
	public Library(User user, Game game) {
		super();
		this.user = user;
		this.game = game;
	}
	public Library(Game game) {
		super();
		this.game = game;
	}
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name="user_id")
	public User getUser() {
		return user;
	}
	public void setUser(User user) {
		this.user = user;
	}
	@ManyToOne
	@JoinColumn(name="game_id")
	public Game getGame() {
		return game;
	}
	public void setGame(Game game) {
		this.game = game;
	}
	@Override
	public String toString() {
		return "Library [id=" + id + ", user=" + user + ", game=" + game + "]";
	}

	
}
